<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <script src="jquery.js" type="text/javascript"></script>
    <title>Document</title>
</head>
<style>
    *{
        margin:0px;
        padding:0px;

    }

    html,body{
        width:100%;
        height:100px;
    }

    canvas{
        display:block;
    }
</style>
<body>
    <canvas id="canvas0"></canvas>
    
</body>
<script>
    $(document).ready(function(){
        var canvas=$("#canvas0");
        var context=canvas.get(0).getContext("2d");
        function resize0(){
            canvas.attr("width",$(window).get(0).innerWidth);
            canvas.attr("height",$(window).get(0).innerHeight);
            context.fillRect(0,0,$(window).get(0).innerWidth/2,$(window).get(0).innerHeight/2);
        }
        resize0();
        $(window).resize(function(){
             resize0();
        })
        
    });
</script>
</html>